mirror of
https://github.com/MapMakersAndProgrammers/TankiOnline2.0DemoClient.git
synced 2025-10-26 01:49:11 -07:00
55 lines
2.1 KiB
ActionScript
55 lines
2.1 KiB
ActionScript
package _codec.versions.version2.a3d.objects
|
|
{
|
|
import alternativa.osgi.OSGi;
|
|
import alternativa.osgi.service.clientlog.IClientLog;
|
|
import alternativa.protocol.ICodec;
|
|
import alternativa.protocol.IProtocol;
|
|
import alternativa.protocol.ProtocolBuffer;
|
|
import alternativa.protocol.info.CollectionCodecInfo;
|
|
import alternativa.protocol.info.TypeCodecInfo;
|
|
import alternativa.types.Float;
|
|
import versions.version2.a3d.objects.A3D2Box;
|
|
|
|
public class CodecA3D2Box implements ICodec
|
|
{
|
|
public static var log:IClientLog = IClientLog(OSGi.getInstance().getService(IClientLog));
|
|
|
|
private var §_-pM§:ICodec;
|
|
|
|
private var §_-2o§:ICodec;
|
|
|
|
public function CodecA3D2Box()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public function init(protocol:IProtocol) : void
|
|
{
|
|
this.§_-pM§ = protocol.getCodec(new CollectionCodecInfo(new TypeCodecInfo(Float,false),false,1));
|
|
this.§_-2o§ = protocol.getCodec(new TypeCodecInfo(int,false));
|
|
}
|
|
|
|
public function decode(protocolBuffer:ProtocolBuffer) : Object
|
|
{
|
|
log = IClientLog(OSGi.getInstance().getService(IClientLog));
|
|
var value_box:Vector.<Number> = this.§_-pM§.decode(protocolBuffer) as Vector.<Number>;
|
|
log.log("codec","struct %1 field %2 value %3","versions.version2.a3d.objects.A3D2Box","box",value_box);
|
|
var value_id:int = int(this.§_-2o§.decode(protocolBuffer) as int);
|
|
log.log("codec","struct %1 field %2 value %3","versions.version2.a3d.objects.A3D2Box","id",value_id);
|
|
return new A3D2Box(value_box,value_id);
|
|
}
|
|
|
|
public function encode(protocolBuffer:ProtocolBuffer, object:Object) : void
|
|
{
|
|
if(object == null)
|
|
{
|
|
throw new Error("Object is null. Use @ProtocolOptional annotation.");
|
|
}
|
|
var struct:A3D2Box = A3D2Box(object);
|
|
this.§_-pM§.encode(protocolBuffer,struct.box);
|
|
this.§_-2o§.encode(protocolBuffer,struct.id);
|
|
}
|
|
}
|
|
}
|
|
|