Nestharus
o-o
- Reaction score
- 84
Put into Mfn.
It's simply an example of how this might be used...You do realise your example won't work, as the structs are public. So a Htn_ prefix is required.
Struct members and methods are public by default, so 'public' keyword isn't needed.
That is true, I didn't think about that =). My mind was elsewhere while I was making this =).This whole thing could be done using textmacros.
There is a very serious point to those 2 lined libraries o-o.I really dislike your coding standards.. With the overkill credits and the crappy 2-lined library.
I'll look into it and see maybe what I could do with them. The idea of just having a handle, setting it's type, and then manipulating it sounds pretty good. I didn't think about it, but I'm not sure how I would do it with how I'm using it at the moment.maybe make the handles delegates?
public interface Handle
public integer h
public hashtable memory
public method getX takes nothing returns real defaults 0.0
public method getY takes nothing returns real defaults 0.0
public method getPlayer takes nothing returns player defaults null
public method getTypeId takes nothing returns integer defaults 0
public method getLife takes nothing returns real defaults 0.0
public method getLevel takes nothing returns integer defaults 0
public method getXP takes nothing returns integer defaults 0
public method getFacing takes nothing returns real defaults 0.0
public method setPosition takes real x, real y returns nothing defaults nothing
public method setPlayer takes player p returns nothing defaults nothing
public method setTypeId takes integer t returns nothing defaults nothing
public method setLife takes real x returns nothing defaults nothing
public method setLevel takes integer x returns nothing defaults nothing
public method setXP takes integer x returns nothing defaults nothing
public method setFacing takes real x returns nothing defaults nothing
public static method create takes nothing
public method make takes player p, integer typeId, real x, real y, real facing returns nothing defaults nothing
public method getHandleId takes nothing returns integer defaults 0
endinterface
public struct Unit extends Handle
public integer h
public hashtable memory
public method make takes player p, integer typeId, real x, real y, real facing returns nothing
set .h = Htn_Unit.create(CreateUnit(p, typeId, x, y, facing))
call SaveInteger(memory, Hcn_HANDLE, GetHandleId((Htn_Unit(.h).h)), this)
endmethod
public method getX takes nothing returns real
return GetUnitX((Htn_Unit(.h).h))
endmethod
public method getY takes nothing returns real
return GetUnitY((Htn_Unit(.h).h))
endmethod
public method getPlayer takes nothing returns player
return GetOwningPlayer((Htn_Unit(.h).h))
endmethod
public method getTypeId takes nothing returns integer
return GetUnitTypeId((Htn_Unit(.h).h))
endmethod
public method getLevel takes nothing returns integer
return GetUnitLevel((Htn_Unit(.h).h))
endmethod
public method getXP takes nothing returns integer
return GetHeroXP((Htn_Unit(.h).h))
endmethod
public method getHandleId takes nothing returns integer
return GetHandleId((Htn_Unit(.h).h))
endmethod
public method getFacing takes nothing returns real
return GetUnitFacing((Htn_Unit(.h).h))
endmethod
public method setPosition takes real x, real y returns nothing
call SetUnitPosition((Htn_Unit(.h).h), x, y)
endmethod
public method setPlayer takes player p returns nothing
call SetUnitOwner((Htn_Unit(.h).h), p, false)
endmethod
public method setLevel takes integer x returns nothing
call SetHeroLevel((Htn_Unit(.h).h), x, false)
endmethod
public method setXP takes integer x returns nothing
call SetHeroXP((Htn_Unit(.h).h), x, false)
endmethod
public method setFacing takes real x returns nothing
call SetUnitFacing((Htn_Unit(.h).h), x)
endmethod
public static method create takes nothing returns thistype
local thistype u = thistype.allocate()
return u
endmethod
endstruct
Are you making extra bj?
The only use I can see for this is slowing down everything in WC3.
I think you missed the boat a bit. Speed and functionality are generally important, whilst convention and credit notes are generally not too worried about.
Please read what this is... it's a library
I lol'ed.
Hashing will faster than this?
I think the "Handle Wrapper" is better name.